﻿Imports Microsoft.Xna.Framework
Imports Microsoft.Xna.Framework.Graphics

Public Class BackgroundImage
    Public Index As Integer
    Public SpriteName As String
    Public Sub New(ByVal Index As Integer, ByVal SpriteName As String)
        Me.Index = Index
        Me.SpriteName = SpriteName
    End Sub

    Private mSpriteTexture As Texture2D
    Public Property SpriteTexture As Texture2D
        Get
            Return mSpriteTexture
        End Get
        Set(ByVal value As Texture2D)
            mSpriteTexture = value
        End Set
    End Property

    Private mPosition As New Vector2(0, 0)
    Public Property Position As Vector2
        Get
            Return mPosition
        End Get
        Set(ByVal value As Vector2)
            mPosition = value
        End Set
    End Property

    Private mSize As Rectangle
    Public Property Size As Rectangle
        Get
            Return mSize
        End Get
        Set(ByVal value As Rectangle)
            mSize = value
        End Set
    End Property

    Public Function GetImageScale(ByVal currentGraphicsDevice As GraphicsDevice) As Decimal
        Return currentGraphicsDevice.Viewport.Height / SpriteTexture.Height
    End Function

    Public Function GetScaledWidth(ByVal currentGraphicsDevice As GraphicsDevice) As Integer
        Dim decScale As Decimal = GetImageScale(currentGraphicsDevice)
        Return Math.Round(SpriteTexture.Width * decScale, 0)
    End Function

    Public Function GetScaledHeight(ByVal currentGraphicsDevice As GraphicsDevice) As Integer
        Dim decScale As Decimal = GetImageScale(currentGraphicsDevice)
        Return Math.Round(SpriteTexture.Width * decScale, 0)
    End Function


    Public Function GetScaledRectangle(ByVal currentGraphicsDevice As GraphicsDevice) As Rectangle
        Dim decScale As Decimal = GetImageScale(currentGraphicsDevice)
        Return New Rectangle(0, 0, GetScaledWidth(currentGraphicsDevice), GetScaledHeight(currentGraphicsDevice))
    End Function

End Class